package com.wc.AlgoOJ_homework.aloj模拟赛.小蓝做实验;

import java.io.*;

/**
 * @Author congge
 * @Date 2024/5/30 22:05
 * @description http://43.138.190.70:8888/p/658?tid=6655c0f9c056ef947a21997d
 */
public class Main {
    static int N = 1000010, idx = 0;
    static boolean[] st = new boolean[N];
    static int[] primes = new int[N >> 3];

    static void ola() {
        st[0] = st[1] = true;
        for (int i = 2; i <= N - 1; i++) {
            if (!st[i]) primes[++idx] = i;
            for (int j = 1; primes[j] <= (N - 1) / i; j++) {
                st[primes[j] * i] = true;
                if (i % primes[j] == 0) break;
            }
        }
    }

    public static void main(String[] args) throws IOException {
        File file = new File("D:\\javaPro\\algorithm-learning-luogu\\src\\com\\wc\\AlgoOJ_homework\\aloj模拟赛\\小蓝做实验\\primes.txt");
        BufferedReader bufferedReader = new BufferedReader(new FileReader(file));
        String line;
        ola();
        int res = 0;
        while ((line = bufferedReader.readLine()) != null) {
            long x = Long.parseLong(line);
            if (isPrime(x)) res++;
        }
        System.out.println(res);
    }

    static boolean isPrime(long x) {
        for (int i = 1; primes[i] <= x / primes[i]; i++) {
            if (x % primes[i] == 0) return false;
        }

        return true;
    }
}
